package ch06.test1;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestUser {
    @Test
    public void test() {
        //实例化Spring的上下文
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationch06test.xml");

        //通过getBean方法根据id获取ben的实例
        User user = (User) ctx.getBean("user", User.class);

        //执行输出方法
        user.print();
    }
    @Test
    public void test1() {
        //实例化Spring的上下文
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationch06test.xml");

        //通过getBean方法根据id获取ben的实例
        User user = (User) ctx.getBean("userP", User.class);

        user.print();
    }
}
